<?php
include_once '../common_mbs.inc.php';
include_once '../smarty.inc.php';

//判断访问权限
$admin_index_module_obj = new osgh_admin_index_module_cls();
$is_warrant = $admin_index_module_obj->is_have_warrant($_ADMIN_ID,'user_list');
if(!$is_warrant) tcmc_cls::ShowMsg("没有权限访问！", "../index_body.html");

$user_obj = new user_cls();
$act = trim($_INPUT['action']);
$user_id  = $_INPUT['user_id'];
if($act =='save')
{
	$type = $_INPUT['user_type_id'];
	$company = $_INPUT['company'];
	$data = array(
			'user_name'   => $_INPUT['user_name'],
			'user_sex' => $_INPUT['user_sex'],	
			'user_type_id' => $type,
			'user_address' => $_INPUT['user_address'],
			'user_phone' => $_INPUT['user_phone'],
			'user_email' => $_INPUT['user_email'],
			'birthday' => strtotime($_INPUT['birthday']),
			'user_status' => $_INPUT['user_status'],			
		);
	if($type == 0)
	{
		$data['pid'] = -1;
		$data['company'] =  0;
	}
	else if($type == 1)
	{
		$data['pid'] = 0;
		$data['company'] =  0;
	}
	else  if($type == 2)
	{
		$data['pid'] =  $_INPUT['pid'];
		$data['company'] =  0;
	}
	else if($type == 3)
	{
		$data['company'] = $company;
		$data['pid'] =  -1;
	}
	if(!empty($_INPUT['pwd']))
	{
		$data['pwd'] = md5($_INPUT['pwd']);
	}
	if(empty($user_id)){		
		$data['ret_addtime'] = time();
		$user_obj->add_user($data);
		tcmc_cls::ShowMsg("添加会员成功！", "user_list.php");
	}else{		  
		   $user_obj->update_user($data, $user_id);
		   tcmc_cls::ShowMsg("修改会员成功！", "user_list.php");
	}
}elseif($act =='del'){
	$user_obj->del_user($user_id);
	tcmc_cls::ShowMsg("删除会员成功！", "user_list.php");
}

?>
